﻿#ifndef QQ_H
#define QQ_H

#include <QWidget>
#include <QLabel>
#include <QMovie>
#include <QSystemTrayIcon>

#include "accountDown.h"
#include "tip.h"
#include "qqmain.h"
#include "sqliteutil.h"
#include "httpclient.h"
#include "fileoperator.h"

#include <QDebug>

#include <QTimer>
#include <QLineEdit>

#include <QPainter>
#include <QPainterPath>
#include <QBitmap>
#include <QPixmap>
#include <QImage>

#include <QMouseEvent>

#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>

#include <QGraphicsDropShadowEffect>
#include <QGraphicsView>
#include <QGraphicsScene>

#include <QDir>
#include <QFileInfo>
#include <QFile>
#include <QTextStream>

#include <QDesktopServices>
#include <QUrl>

#include <QJsonDocument>
#include <QJsonObject>

#include <QSysInfo>

#include <QScreen>
QT_BEGIN_NAMESPACE
namespace Ui { class QQ; }
QT_END_NAMESPACE

class QQ : public QWidget
{
    Q_OBJECT

public:
    QQ(QWidget *parent = nullptr);
    ~QQ();
signals:
    void login(const QString &wsAddr,const QString &email,const QString &username,const bool &isDownLoad,const QString &sign,const QString &token);
    void quit();
protected:
    void mousePressEvent(QMouseEvent* event)override;
    void mouseMoveEvent(QMouseEvent* event)override;
    void mouseReleaseEvent(QMouseEvent* event)override;
    void keyPressEvent(QKeyEvent* event)override;
    void timerEvent(QTimerEvent *event);
private:
    Ui::QQ *ui;
    accountDown* menuWidget=nullptr;
    Tip* accTip=nullptr;
    Tip* pwdTip=nullptr;
    QMovie *movie=nullptr;
    HttpClient* httpClient=nullptr;
    FileOperator* fileOperator=nullptr;
    SQLiteUtil* sQLiteUtil=nullptr;

    int timeID;
    int TipLife;
    bool isTimerRunning = false;//标记Tip的窗口出现
    bool isDragging=false;  //标记窗口是否拖拽
    QString accountImgPath=":/background/imagesRes/account.png";
    QString accountImgPath_active=":/background/imagesRes/account_active.png";
    QString pwdImgPath=":/background/imagesRes/pwd.png";
    QString pwdImgPath_active=":/background/imagesRes/pwd_active.png";
    QPoint lastPos;
    QNetworkReply* loginReply=nullptr;

    void createShadow();
    void createHeadShadow();

    void loadHttpComponentRespond();
    void loadBaseComponentRespond();

    void tipHide();
    void drawHeadImg(QLabel *label,QString imgRes);
    bool checkLineEdit(QLineEdit* LEdit);
    bool checkDevice();
    void setRecentLogin(QVariantMap& resultMap);
    void getRecentLogin();
    void setStyleShowDown();
    void setStyleShowDown_active();
    void setStyleAccWT();
    void setStyleAccWT_active();
    void setStylePwdWT();
    void setStylePwdWT_active();
};
#endif // QQ_H
